package com.ruoyi.back.controller.v3

import com.ruoyi.app.common.Data
import com.ruoyi.app.common.PageData
import com.ruoyi.app.common.pageInfo
import com.ruoyi.back.domain.v3.SensitiveWord
import com.ruoyi.back.service.v3.SensitiveWordService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController


@RestController
@RequestMapping("/system/sensitiveWord")
@Api(tags = ["敏感词管理"])
class SensitiveWordController {

    @Autowired
    private lateinit var sensitiveWordService: SensitiveWordService


    @PostMapping("save")
    @ApiOperation("保存或者修改敏感词")
    fun saveSensitiveWord(@RequestBody sensitiveWord: SensitiveWord): Data<Boolean> =
        sensitiveWordService.saveSensitiveWord(sensitiveWord)

    @GetMapping("delete")
    @ApiOperation("批量移除")
    fun removeSensitiveWord(ids: String): Data<Boolean> = sensitiveWordService.removeSensitiveWord(ids)

    @GetMapping("select")
    @ApiOperation("获取敏感词列表")
    fun selectSensitiveWord(sensitiveWord: String): PageData<SensitiveWord> =
        sensitiveWordService.selectSensitiveWord(sensitiveWord).pageInfo()
}